<template>
  <div class="app-container">
    <div class="title">个人信息</div>
    <el-tabs type="border-card">
      <el-tab-pane label="基本信息">
        <div class="form">
          <div class="form-top">
            <el-form ref="ruleForm1" :model="ruleForm1" :rules="rules" label-width="120px" class="demo-ruleForm">
              <div class="form-group">
                <div class="group_item">
                  <div class="group_item_left">
                    <div style="width:60%">
                      <div class="group_name">账户信息：</div>
                      <el-form-item label="用户名：">
                        <el-input v-model="ruleForm1.user_name" placeholder="请输入账户信息" :disabled="true" />
                      </el-form-item>
                      <div class="group_tip">TIPS：注意用户名不可修改</div>
                      <el-form-item label="密码：">
                        <el-input v-model="ruleForm1.pass_wd" type="password" show-password placeholder="请输入密码" :disabled="true" />
                      </el-form-item>
                      <div class="group_tip">TIPS：如不修改密码可不填写</div>
                      <el-form-item label="手机号码：" prop="phone">
                        <el-input v-model="ruleForm1.phone" type="tel" placeholder="请输入手机号码" :disabled="true" />
                      </el-form-item>
                      <el-form-item
                        label="邮箱："
                      >
                        <el-input v-model="ruleForm1.email" placeholder="请输入邮箱" :disabled="true" />
                      </el-form-item>
                    </div>
                  </div>
                  <div class="group_item_right">
                    <div class="group_name">用户头像：</div>
                    <el-form-item
                      label=""
                    >
                      <el-image class="userAvatar" :src="ruleForm1.avatar" />
                    </el-form-item>
                  </div>
                </div>
              </div>
            </el-form>
          </div>
          <div class="form-middel">
            <el-form ref="ruleForm2" :model="ruleForm1" :rules="rules" label-width="130px" class="demo-ruleForm">
              <div class="form-group">
                <div class="group_item">
                  <div class="group_item_left">
                    <div class="group_name">教师信息：</div>
                    <div style="width:60%">
                      <el-form-item label="教师姓名：" prop="nickname">
                        <el-input v-model="ruleForm1.nickname" placeholder="请输入教师姓名" :disabled="true" />
                      </el-form-item>
                      <el-form-item label="性别：">
                        <el-radio-group v-model="ruleForm1.sex">
                          <el-radio label="男" />
                          <el-radio label="女" />
                        </el-radio-group>
                      </el-form-item>
                      <el-form-item label="出生年月：">
                        <el-date-picker v-model="ruleForm1.brith" type="date" placeholder="请选择出生年月" style="width: 100%;" value-format="yyyy-MM-dd hh:mm:ss" />
                      </el-form-item>
                      <el-form-item
                        label="身份证编号:"
                      >
                        <el-input v-model="ruleForm1.Id_card" placeholder="请输入身份证编号" />
                      </el-form-item>
                      <el-form-item
                        label="证件上传:"
                      >
                        <div class="IDcardUpload">
                          <upload1
                            ref="upload1"
                            :config="config"
                            :type="0"
                            :urlnow="{url:ruleForm1.card}"
                            :upload-id="'uploadId1'"
                            @filepath="filepath(arguments)"
                          />
                          <upload1
                            ref="upload2"
                            :config="config"
                            :type="1"
                            :urlnow="{url:ruleForm1.card_back}"
                            :upload-id="'uploadId2'"
                            @filepath="filepath2(arguments)"
                          />
                        </div>
                      </el-form-item>
                    </div>
                  </div>
                  <div class="group_item_right2">
                    <div class="group_name"><p class="err-msg" v-html="err" /></div>
                    <div style="width:60%">

                      <el-form-item label="进校时间：">
                        <el-date-picker v-model="ruleForm1.school_time" type="date" placeholder="请选择进校时间" style="width: 100%;" value-format="yyyy-MM-dd hh:mm:ss" />
                      </el-form-item>
                      <el-form-item
                        label="教师身份:"
                      >
                        <el-select v-model="teachers_identity" multiple placeholder="请选择教师身份" style="width:100%" @change="teachers_identityChange">
                          <el-option
                            v-for="item in teacherIdentityOptions"
                            :key="item.value"
                            :label="item.value"
                            :value="item.value"
                          />
                        </el-select>
                      </el-form-item>
                      <el-form-item
                        label="任教年级:"
                      >
                        <el-select v-model="grade" multiple placeholder="请选择任教年级" style="width:100%" @change="gradeChange">
                          <el-option
                            v-for="item in teacherLevelOptions"
                            :key="item.label"
                            :label="item.label"
                            :value="item.label"
                          />
                        </el-select>
                      </el-form-item>
                      <el-form-item
                        label="任教科目:"
                      >
                        <el-select v-model="ruleForm1.subject_id" placeholder="请选择任教科目" style="width:100%">
                          <el-option
                            v-for="item in teacherSubjectOptions"
                            :key="item.label"
                            :label="item.label"
                            :value="item.label"
                            :disabled="true"
                          />
                        </el-select>
                      </el-form-item>
                      <el-form-item label="教师资格证编号：">
                        <el-input v-model="ruleForm1.teacher_qualification" placeholder="请输入教师资格证编号" />
                      </el-form-item>
                      <el-form-item
                        label="资格证证件上传:"
                      >
                        <upload1
                          ref="upload3"
                          :config="config"
                          :type="2"
                          :urlnow="{url:ruleForm1.teacher_picture}"
                          :upload-id="'uploadId3'"
                          @filepath="filepath3(arguments)"
                        />
                      </el-form-item>
                    </div>
                  </div>
                </div>
              </div>
            </el-form>
          </div>
          <div class="form-bottom">
            <el-form ref="ruleForm3" :model="ruleForm1" :rules="rules" label-width="140px" class="demo-ruleForm">
              <div class="form-group">
                <div class="group_item">
                  <div class="group_item_left">
                    <div style="width:60%">
                      <div class="group_name">其他信息：</div>
                      <el-form-item label="紧急联系人姓名：" prop="emergency">
                        <el-input v-model="ruleForm1.emergency" placeholder="请输入紧急联系人姓名" />
                      </el-form-item>
                      <el-form-item label="紧急联系人电话：" prop="emergency_phone">
                        <el-input v-model="ruleForm1.emergency_phone" type="tel" placeholder="请输入紧急联系人电话" />
                      </el-form-item>
                      <el-form-item label="与本人关系：" prop="personal_relationship">
                        <el-input v-model="ruleForm1.personal_relationship" placeholder="请输入与本人关系" />
                      </el-form-item>
                      <el-form-item label="家庭住址：">
                        <div class="areaSelect">
                          <el-select v-model="provinec_id" filterable placeholder="请选择省份">
                            <el-option
                              v-for="item in provinceData"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select>
                          <el-select v-model="city_id" filterable placeholder="请选择市" style="margin-left:10px">
                            <el-option
                              v-for="item in cityData"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          <!-- <el-input v-model="ruleForm1.otherAddress" /> -->
                          </el-select>
                          <el-select v-model="area_id" filterable placeholder="请选择地区" style="margin-left:10px">
                            <el-option
                              v-for="item in areaData_ary"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select>
                        </div>
                        <div class="detailAddress">
                          <el-input v-model="ruleForm1.home_address" placeholder="请输入详细地址" />
                        </div>
                      </el-form-item>
                    </div>
                  </div>
                  <div class="group_item_right" />
                </div>
              </div>
            </el-form>
          </div>
        </div></el-tab-pane>
      <el-tab-pane label="教师简介">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>教师经历</span>
            <div class="clearfix-buttton"><el-button v-if="experienceList.length<10" type="primary" @click="addExperience">新增经历</el-button><el-button v-if="experienceList.length>1" type="danger" @click="delExperience(experienceList.length-1)">删除经历</el-button></div>
          </div>
          <div v-for="(item,index) in experienceList" :key="index" class="teacherExperience">
            <div class="time">
              <div class="time-label">经历时间：</div>
              <el-date-picker
                v-model="item.totalTime"
                style="width:70%;"
                type="daterange"
                value-format="yyyy-MM-dd hh:mm:ss"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="timeChange(item.totalTime,index)"
              /></div>
            <div class="experience">
              <div class="time-label">
                经历内容：
              </div>
              <el-input
                v-model="item.experience"
                type="textarea"
                :autosize="{ minRows: 4, maxRows: 100 }"
                style="width:70%;"
                placeholder="请输入经历内容"
              />
            </div>
          </div>

        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>教学成果</span>
            <div class="clearfix-buttton"><el-button v-if="achievementList.length<10" type="primary" @click="addAchievement">新增成果</el-button><el-button v-if="achievementList.length>1" type="danger" @click="delAchievement(achievementList.length-1)">删除成果</el-button></div>
          </div>
          <div v-for="(item,index) in achievementList" :key="index" class="achievement-item">
            <div class="achievement-label">
              成果内容：
            </div>
            <el-input
              v-model="item.results"
              type="textarea"
              :autosize="{ minRows: 4, maxRows: 100 }"
              style="width:70%;"
              placeholder="请输入成果内容"
            />
          </div>
        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>教学特点</span>
            <div class="clearfix-buttton"><el-button v-if="characteristicsList.length<10" type="primary" @click="addCharacteristics">新增特点</el-button><el-button v-if="characteristicsList.length>1" type="danger" @click="delCharacteristics(characteristicsList.length-1)">删除特点</el-button></div>
          </div>
          <div v-for="(item,index) in characteristicsList" :key="index" class="achievement-item">
            <div class="achievement-label">
              特点内容：
            </div>
            <el-input
              v-model="item.characteristics"
              type="textarea"
              :autosize="{ minRows: 4, maxRows: 100 }"
              style="width:70%;"
              placeholder="请输入特点内容"
            />
          </div>
        </el-card>
      </el-tab-pane>
    </el-tabs>

    <el-button type="primary" class="submit" :loading="loading" @click="saveSubmit">保存提交</el-button>
  </div>
</template>

<script>
import upload1 from '@/components/upload/index1'
import { uploadConfig } from '@/components/upload/config/upload'
import provinceData from '@/assets/js/level_linkage/province'
import cityData from '@/assets/js/level_linkage/city'
import areaData_ary from '@/assets/js/level_linkage/area'
import { saveTeacher, addExperience, addResults, addCharacteristics, getTeacherById } from '@/api/teacher'
import { get_allInstitutionalRole } from '@/api/institutionalRole'
import { delSessionInfo } from '@/utils/auth'
export default {
    components: {
        upload1
    },
    props: {},
    data() {
        var checkPhone = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('手机号不能为空'))
            } else {
                const reg = /^[1](([3][0-9])|([4][0,1,4-9])|([5][0-3,5-9])|([6][2,5,6,7])|([7][0-8])|([8][0-9])|([9][0-3,5-9]))[0-9]{8}$/
                console.log(reg.test(value))
                if (reg.test(value)) {
                    callback()
                } else {
                    return callback(new Error('请输入正确的手机号'))
                }
            }
        }

        return {
            config: uploadConfig,
            loading: false,
            filepathli: [],
            filepath2li: [],
            filepath3li: [],
            filepath4li: [],
            experienceList: [{
                teacher_id: '',
                begin_time: null,
                end_time: null,
                totalTime: null,
                experience: ''
            }],
            achievementList: [{
                teacher_id: '',
                results: ''
            }],
            characteristicsList: [{
                teacher_id: '',
                characteristics: ''
            }],
            id: this.$store.getters.userId,
            ruleForm1: {
                user_name: '',
                pass_wd: '',
                phone: '',
                email: '',
                nickname: '',
                sex: '',
                brith: '',
                Id_card: '',
                card: '',
                card_back: '',
                teacher_qualification: '',
                school_time: '',
                teachers_identity: '',
                grade: '',
                subject_id: '',
                teacher_picture: '',
                emergency: '',
                emergency_phone: '',
                personal_relationship: '',
                home_address: '', // 详细地址
                avatar: ''
            },
            err: '&#12288;',
            rules: {
                phone: [
                    { required: true, validator: checkPhone, trigger: 'blur' }
                ],
                avatar: [
                    { required: true, message: '请选择头像', trigger: 'blur' }
                ],
                emergency: [
                    { required: true, message: '请填写紧急联系人姓名', trigger: 'blur' }
                ],
                nickname: [{ required: true, message: '请填写教师姓名', trigger: 'blur' }],
                emergency_phone: [
                    { required: true, validator: checkPhone, trigger: 'blur' }
                ],
                personal_relationship: [
                    { required: true, message: '请填写与本人关系', trigger: 'blur' }
                ]
            },
            // 地区数据
            provinceData,
            cityData: [],
            areaData_ary: [],
            provinec_id: null,
            city_id: null,
            area_id: null,
            // 教师身份选项
            teacherIdentityOptions: [],
            // 任教年级选项
            teacherLevelOptions: [
                { label: '一年级', value: 1 },
                { label: '二年级', value: 2 },
                { label: '三年级', value: 3 },
                { label: '四年级', value: 4 },
                { label: '五年级', value: 5 },
                { label: '六年级', value: 6 },
                { label: '七年级', value: 7 },
                { label: '八年级', value: 8 },
                { label: '九年级', value: 9 },
                { label: '高一', value: 10 },
                { label: '高二', value: 11 },
                { label: '高三', value: 12 }
            ],
            // 任教科目选项
            teacherSubjectOptions: [],
            teachers_identity: [],
            grade: []
        }
    },
    computed: {},
    watch: {
        provinec_id(item) {
            if (this.provinec_id != item) {
                this.city_id = null
                this.area_id = null
                this.isEmtry = true
            } else {
                this.isEmtry = false
            }
            console.log('省item', item)
            this.cityInitData(item)
        },
        city_id(item) {
            console.log('市item', item)
            if (this.isEmtry) {
                this.area_id = null
            }
            this.areaInitData(item)
        }
    },
    beforeCreate() {
    // 生命周期钩子：组件实例刚被创建，组件属性计算之前，如 data 属性等
    },
    created() {
    // 生命周期钩子：组件实例创建完成，属性已绑定，但 DOM 还未生成，el 属性还不存在
    // 初始化渲染页面
    },
    beforeMount() {
    // 生命周期钩子：模板编译/挂载之前
    },
    mounted() {
    // 生命周期钩子：模板编译、挂载之后（此时不保证已在 document 中）
        this.getTeacherIdentity()
        //  获取老师信息
        console.log('id', this.id)
        this.getTeacherInfo()
    },
    methods: {
        // 获通过id取老师信息
        getTeacherInfo() {
            getTeacherById({
                id: this.id
            }).then(res => {
                console.log('res>>>>>>>>>>>>', res)
                if (res.code === 200) {
                    // 获取城市列表
                    if (res.data.province) {
                        this.cityInitData(res.data.province)
                    }
                    // 获取地区列表
                    if (res.data.city) {
                        this.areaInitData(res.data.city)
                    }
                    if (Array.isArray(res.data)) {
                        console.log('值为空')
                    } else {
                        this.ruleForm1.user_name = res.data.user_name
                        // 密码需解密
                        this.ruleForm1.phone = res.data.phone
                        this.ruleForm1.email = res.data.email
                        this.ruleForm1.nickname = res.data.nickname
                        this.ruleForm1.sex = res.data.sex
                        this.ruleForm1.brith = res.data.brith
                        this.ruleForm1.Id_card = res.data.Id_card
                        this.ruleForm1.card = res.data.card
                        this.ruleForm1.card_back = res.data.card_back
                        this.ruleForm1.teacher_qualification = res.data.teacher_qualification
                        this.ruleForm1.school_time = res.data.school_time
                        this.ruleForm1.teachers_identity = res.data.teachers_identity
                        this.ruleForm1.grade = res.data.grade ? res.data.grade : ''
                        this.ruleForm1.subject_id = res.data.subject_id ? res.data.subject_id : ''
                        this.ruleForm1.teacher_picture = res.data.teacher_picture
                        this.ruleForm1.emergency = res.data.emergency
                        this.ruleForm1.emergency_phone = res.data.emergency_phone
                        this.ruleForm1.personal_relationship = res.data.personal_relationship
                        this.ruleForm1.home_address = res.data.home_address
                        this.ruleForm1.avatar = res.data.avatar
                        this.provinec_id = res.data.province ? res.data.province + '' : ''
                        this.city_id = res.data.city ? res.data.city + '' : res.data.city
                        this.area_id = res.data.area ? res.data.area + '' : res.data.area
                        if (this.provinec_id === 0) {
                            this.provinec_id = ''
                        }
                        if (this.city_id === 0) {
                            this.city_id = ''
                        }
                        if (this.area_id === 0) {
                            this.area_id = ''
                        }
                        // 教师身份
                        if (res.data.teachers_identity) {
                            this.teachers_identity = res.data.teachers_identity.split(',')
                        }
                        // 任教年级
                        if (res.data.grade) {
                            this.grade = res.data.grade.split(',')
                        }
                        if (res.data.experience.length > 0) {
                            this.experienceList = res.data.experience.map((item, index) => {
                                item.totalTime = [item.begin_time, item.end_time]
                                return item
                            })
                            console.log('经历列表', this.experienceList)
                        }
                        if (res.data.results.length > 0) {
                            this.achievementList = res.data.results
                            console.log('成果列表', this.achievementList)
                        }
                        if (res.data.characteristics.length > 0) {
                            this.characteristicsList = res.data.characteristics
                            console.log('成果列表', this.characteristicsList)
                        }
                    }
                }
            })
        },
        // 获取教师身份
        getTeacherIdentity() {
            get_allInstitutionalRole({}).then(res => {
                console.log('获取教师身份', res)
                var teacherIdentityOptions = []
                res.data.forEach((item, index) => {
                    if (item.sub.length > 0) {
                        item.sub.forEach((item1, index1) => {
                            if (item1.sub.length > 0) {
                                item1.sub.forEach((item2, index2) => {
                                    teacherIdentityOptions.push({
                                        value: item1.role_name + '/' + item2.role_name
                                    })
                                })
                            }
                        })
                    }
                })
                this.teacherIdentityOptions = teacherIdentityOptions
            })
        },
        teachers_identityChange(item) {
            this.ruleForm1.teachers_identity = ''
            this.ruleForm1.teachers_identity = item.toString()
        },
        gradeChange(item) {
            this.ruleForm1.grade = ''
            this.ruleForm1.grade = item.toString()
        },
        // 上传图片方法
        filepath(param) {
            console.log('上传图片', param[0])
            this.ruleForm1.card = param[1] + param[0]
            this.filepathli = [
                {
                    filepath: param[0]
                }
            ]
        },
        filepath2(param) {
            console.log('上传图片', param[0])
            this.ruleForm1.card_back = param[1] + param[0]
            this.filepath2li = [
                {
                    filepath: param[0]
                }
            ]
        },
        filepath3(param) {
            console.log('上传图片', param[0])
            this.ruleForm1.teacher_picture = param[1] + param[0]
            this.filepath3li = [
                {
                    filepath: param[0]
                }
            ]
        },
        filepath4(param) {
            console.log('上传图片', param[0])
            this.ruleForm1.avatar = param[1] + param[0]
            console.log('avatar', this.ruleForm1.avatar)
            if (this.ruleForm1.avatar) {
                console.log('有上传的图片')
                this.$refs['ruleForm1'].clearValidate('avatar')
                delete this.$refs['ruleForm1'].rules.avatar
            }
            this.filepath4li = [
                {
                    filepath: param[0]
                }
            ]
        },
        // 新增经历
        addExperience() {
            this.experienceList.push({
                teacher_id: '',
                begin_time: null,
                end_time: null,
                totalTime: null,
                experience: ''

            })
        },
        // 时间选择
        timeChange(time, index) {
            this.experienceList[index].begin_time = time[0]
            this.experienceList[index].end_time = time[1]
            console.log('this.experienceList', this.experienceList)
        },
        // 删除经历
        delExperience(index) {
            this.experienceList.splice(index, 1)
        },
        // 增加成果
        addAchievement() {
            this.achievementList.push({
                teacher_id: '',
                results: ''
            })
        },
        // 删除成果
        delAchievement(index) {
            this.achievementList.splice(index, 1)
        },
        // 增加特点
        addCharacteristics() {
            this.characteristicsList.push({
                teacher_id: '',
                characteristics: ''
            })
        },
        // 删除特点
        delCharacteristics(index) {
            this.characteristicsList.splice(index, 1)
        },
        // 根据省拿到市
        cityInitData(item) {
            if (item) {
                var city_ary = []
                for (var i in cityData) {
                    for (var k in cityData[i]) {
                        if (cityData[i][k].value.substring(0, 2).indexOf(item) > -1) {
                            city_ary.push(cityData[i][k])
                        }
                    }
                }
                this.cityData = city_ary
            }
            console.log('城市列表', this.cityData)
        },
        // 根据市拿到区
        areaInitData(item) {
            if (item) {
                var area_ary = []
                for (var i in areaData_ary) {
                    for (var k in areaData_ary[i]) {
                        var arr = areaData_ary[i][k]
                        for (var j in areaData_ary[i][k]) {
                            if (arr[j].value.substring(0, 4).indexOf(item) > -1) {
                                area_ary.push(arr[j])
                            }
                        }
                    }
                }
                this.areaData_ary = area_ary
            }
            console.log('地区列表', this.areaData_ary)
        },
        //   保存提交
        saveSubmit() {
            const rule1 = new Promise((resolve, reject) => {
                this.$refs['ruleForm1'].validate(valid => {
                    if (valid) {
                        resolve()
                    } else {
                        console.log('表单1验证不通过')
                        return false
                    }
                })
            })
            const rule2 = new Promise((resolve, reject) => {
                this.$refs['ruleForm2'].validate(valid => {
                    if (valid) {
                        resolve()
                    } else {
                        console.log('表单2验证不通过')
                        return false
                    }
                })
            })
            const rule3 = new Promise((resolve, reject) => {
                this.$refs['ruleForm3'].validate(valid => {
                    if (valid) {
                        resolve()
                    } else {
                        console.log('表单3验证不通过')
                        return false
                    }
                })
            })
            Promise.all([rule1, rule2, rule3]).then(async() => {
                this.loading = true
                // teacher_add
                // var teacher_base = {
                //     id: this.id,
                //     user_name: this.ruleForm1.user_name,
                //     pass_wd: this.ruleForm1.pass_wd,
                //     phone: this.ruleForm1.phone,
                //     email: this.ruleForm1.email,
                //     nickname: this.ruleForm1.nickname,
                //     parent_id: this.$store.getters.institute_id,
                //     grade: this.ruleForm1.grade,
                //     subject_id: this.ruleForm1.subject_id,
                //     avatar: this.ruleForm1.avatar
                // }
                // teacher_save
                var objData = {
                    sex: this.ruleForm1.sex,
                    brith: this.ruleForm1.brith,
                    Id_card: this.ruleForm1.Id_card,
                    card: this.ruleForm1.card,
                    card_back: this.ruleForm1.card_back,
                    teacher_qualification: this.ruleForm1.teacher_qualification,
                    teacher_picture: this.ruleForm1.teacher_picture,
                    school_time: this.ruleForm1.school_time,
                    grade: this.ruleForm1.grade,
                    teachers_identity: this.ruleForm1.teachers_identity,
                    emergency: this.ruleForm1.emergency,
                    personal_relationship: this.ruleForm1.personal_relationship,
                    emergency_phone: this.ruleForm1.emergency_phone,
                    home_address: this.ruleForm1.home_address,
                    province: Number(this.provinec_id),
                    city: Number(this.city_id),
                    area: Number(this.area_id),
                    nickname: this.ruleForm1.nickname
                }

                // console.log('参数1', teacher_base)
                // addTeacher(teacher_base).then(async res => {
                //     console.log('res', res)
                //     if (res.code === 200) {
                //         if (res.data.code) {
                //             this.loading = false
                //             this.$message.error(res.data.msg)
                //         } else {
                // 图片上传到服务器
                // await this.$refs.upload4.putFile(this.filepath4li)
                // 添加额外老师信息
                objData.id = this.id
                console.log('参数2', objData)
                await saveTeacher(objData).then(async res1 => {
                    console.log('添加老师额外信息', res1)
                    if (res1.code === 200) {
                        if (this.ruleForm1.card) {
                            await this.$refs.upload1.putFile(this.filepathli)
                        }
                        if (this.ruleForm1.card_back) {
                            await this.$refs.upload2.putFile(this.filepath2li)
                        }
                        if (this.ruleForm1.teacher_picture) {
                            await this.$refs.upload3.putFile(this.filepath3li)
                        }
                        // 添加经历
                        var experienceList = []
                        for (let i = 0; i < this.experienceList.length; i++) {
                            if (this.experienceList[i].totalTime || this.experienceList[i].experience) {
                                this.experienceList[i].teacher_id = this.id
                                delete this.experienceList[i].totalTime
                                experienceList.push(this.experienceList[i])
                            }
                        }
                        if (experienceList.length > 0) {
                            var experienceObj = {
                                teacher_experience: experienceList
                            }
                            console.log('参数3', experienceObj)
                            await addExperience(experienceObj).then(res => {
                                console.log('添加经历返回', res)
                                if (res.code === 200) {
                                    console.log('添加经历成功')
                                } else {
                                    this.loading = false
                                    return this.$message.error('添加失败')
                                }
                            })
                        }
                        // 添加成果
                        var achievementList = []
                        for (let j = 0; j < this.achievementList.length; j++) {
                            if (this.achievementList[j].results) {
                                this.achievementList[j].teacher_id = this.id
                                achievementList.push(this.achievementList[j])
                            }
                        }
                        if (achievementList.length > 0) {
                            var achievementObj = {
                                teacher_results: achievementList
                            }
                            console.log('参数4', achievementObj)
                            await addResults(achievementObj).then(res => {
                                console.log('添加成果返回', res)
                                if (res.code === 200) {
                                    console.log('添加成果成功')
                                } else {
                                    this.loading = false
                                    return this.$message.error('添加失败')
                                }
                            })
                        }
                        // 添加特长
                        var characteristicsList = []
                        for (let k = 0; k < this.characteristicsList.length; k++) {
                            if (this.characteristicsList[k].characteristics) {
                                this.characteristicsList[k].teacher_id = this.id
                                characteristicsList.push(this.characteristicsList[k])
                            }
                        }
                        if (characteristicsList.length > 0) {
                            var characteristicsObj = {
                                teacher_characteristics: characteristicsList
                            }
                            console.log('参数5', characteristicsObj)
                            await addCharacteristics(characteristicsObj).then(res => {
                                console.log('添加特长', res)
                                if (res.code === 200) {
                                    console.log('添加特长成功')
                                } else {
                                    return this.$message.error('添加失败')
                                }
                            })
                        }
                        this.$notify({
                            title: '成功',
                            message: '修改个人信息成功',
                            type: 'success'
                        })
                        // location.reload()
                        setTimeout(() => {
                            this.loading = false
                            delSessionInfo()
                            location.reload()
                        }, 1500)
                        // 返回上一页
                    } else {
                        this.loading = false
                        this.$message.error('添加失败')
                    }
                })
                //         }
                //     }
                // })
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.title{
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
}
.form{
    width: 100%;
    .form-group{
        width: 100%;
    }
    .group_name{
        margin: 20px;
    }
    .group_item{
         width: 100%;
         display: flex;
         .group_item_left{
             flex:1
         }
         .group_item_right{
              flex:1;
         }
         .group_item_right2{
              flex:1;
         }
    }
    .form-top{
    }
}
.submit{
    margin-top: 20px;
    float: right;
}
.group_tip{
    color:red;
    padding-left: 120px;
    padding-bottom:20px;
}
.IDcardUpload{
    min-width: 366px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

// 教师简介
.box-card{
    // height: 400px;
    margin-top: 30px;
    &:first-child{
        margin-top: 0px;
    }
    .clearfix{
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        &::after{
            content: none;
        }

    }
}
.teacherExperience{
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 30px;
    &:first-child{
        margin-top: 0px;
    }
.time{
    display: flex;
    align-items: center;
    width: 60%;
    .time-label{
        margin-right: 30px;
    }
}
.experience{
    display: flex;
    align-items: center;
    margin-top: 10px;
    .time-label{
        margin-right: 30px;
    }
}

}
.achievement-item{
    &:first-child{
        margin-top: 0px;
    }
    margin-top: 20px;
    display: flex;
    .achievement-label{
        margin-right: 30px;
    }
}
.areaSelect{
  display: flex;
  align-items: center;
  min-width:366px;
}
.detailAddress{
    margin-top: 10px;
}
.userAvatar{
    height: 100px;width: 150px;
    margin-left: 20px;
}
</style>
